package pure.csw.redis;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import java.util.HashMap;

public class PureJedis {
    public static void main(String[] args) {
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxTotal(20);//设置最大连接数
        config.setMaxIdle(2);//设置最大连接空闲数
        JedisPool pool = new JedisPool(config, "192.168.226.129",6379);
        Jedis jedis = pool.getResource();
        String res0 = jedis.set("name","alichoto");//String操作
        System.out.println("set:"+res0);
        HashMap<String,String> map = new HashMap<>();
        map.put("num","61616");
        map.put("age","23");
        map.put("username","Dell");
        String res1 = jedis.hmset("stu1",map);//hash操作
        System.out.println("hmset:"+res1);
        long res2 = jedis.lpush("node","1","2","3");//list操作
        System.out.println("lpush:"+res2);
        long res3 = jedis.zadd("ordered set",12,"member1");//zset操作
        System.out.println("zadd:" + res3);
        Long res4 = jedis.sadd("set", "package 1", "package 2");
        System.out.println("sadd:" + res4);//set操作
        pool.close();
    }
}
